# -*- Makefile -*-
RM = rm -f
MKDIR = mkdir -p

CC = g++
CXX = g++
STRIP = strip
CXXFLAGS = -D$(TERMULA2X_BUILD) -O3 -I"/usr/include/SDL" -I"include"
LDFLAGS = -lpthread -lSDL_image -lSDL -lutil
STRIPFLAGS = -R .comment -R .note -R .note.ABI-tag

OBJS  = obj/termula2x.o obj/pty.o obj/stermbutton.o obj/font.o obj/stermsection.o obj/stermkeyboard.o obj/stermkey.o obj/touchscreen.o

TARGET = bin/termula2x-linux

obj/%.o: src/%.cpp
		$(CXX) $(CXXFLAGS) -o $@ -c $<

obj/%.o: src/%.c
		$(CC) $(CXXFLAGS) -o $@ -c $<

all: dir $(TARGET)

dir:
	@if [ ! -d obj ]; then $(MKDIR) obj; fi

$(TARGET): $(OBJS)
		@echo "*** Linking $(TARGET)..."
		$(CXX) -o $(TARGET) $(OBJS) $(LDFLAGS)
		$(STRIP) $(TARGET) #Don't strip if symbols are needed for gprof

clean:
		$(RM) obj/*.o $(TARGET)
